package com.sbj.service.impl;
import cn.hutool.core.convert.Convert;
import cn.hutool.core.lang.TypeReference;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.sbj.dto.req.TransferReq;
import com.sbj.dto.res.TransferRes;
import com.sbj.entity.Transfer;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sbj.mapper.TransferMapper;
import com.sbj.service.TransferService;
import com.zmh.framework.constants.Constants;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * @author summer
 * @version 1.0
 * @date 2024/8/27 11:19
 */
@Service
@Transactional(rollbackFor = Exception.class)
public class TransferServiceImpl extends ServiceImpl<TransferMapper, Transfer> implements TransferService {

    @Override
    public Page<TransferRes> lists(TransferReq transferReq) {
        Page<Transfer> page = new Page<>(transferReq.getPageNum(),transferReq.getPageSize());
        return Convert.convert(new TypeReference<Page<TransferRes>>() {}, this.page(page));
    }

    @Override
    public Transfer findOne() {
         return this.list().get(Constants.ZERO);
    }
}
